package com.gitee.cirnochat.common.event.listener;


import com.gitee.cirnochat.common.event.UserEvent;
import com.gitee.cirnochat.user.service.strategy.UserStateStrategyContext;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class UserStateListener {

    private final UserStateStrategyContext userStateStrategyContext;

    /**
     * 用户状态事件监听器
     * @param event 用户状态事件
     */
    @EventListener
    public void handleUserEvent(UserEvent event) {
        userStateStrategyContext.execute(event.getUserId(),event.getStatus());
    }
}
